package com.amado.example.springcloudnacos;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@Controller
@RequestMapping("config")
@RefreshScope
public class ConfigController {

    @Value("${useLocalCache:false}")
    private boolean useLocalCache;
    @Value("${userName:aa}")
    private String userName;
    @Value("${password:1234}")
    private String password;

    @RequestMapping(value = "/get", method = GET)
    @ResponseBody
    public String get() {
        return Boolean.valueOf(useLocalCache)+" "+userName+" "+password;
    }
}